package generics;

/**
 * @author 杨宇
 * @version 1.0 2016/11/2
 */
public class E23_FactoryConstraint {

    public static void main(String[] args) {
        new Foo2<Integer>(new IntegerFactory(),4);
    }
}

interface FactoryI<T> {
    T create(int n);
}

class Foo2<T> {
    private T x;

    public <F extends FactoryI<T>> Foo2(F factory, int n) {
        x = factory.create(n);
    }
}

class IntegerFactory implements FactoryI<Integer> {
    @Override
    public Integer create(int n) {
        return new Integer(n);
    }
}
